/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import connectivity.QueryManager;
import java.awt.Color;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import main.BarApplication;
import model.Branch;
import model.GroupActivity;
import net.proteanit.sql.DbUtils;



/**
 *
 * @author Home
 */
public class GroupActivityOverview extends javax.swing.JPanel {

     SimpleDateFormat dateForm = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    ResultSet rs = null;
    private LoginScreen login;
    public GroupActivityOverview(LoginScreen login) {
        initComponents();
        this.login = login;
        TableCoachDeelnemers();

        //geeft lijst met vestigingen in de comboBox
        QueryManager queryManager = BarApplication.getQueryManager();
        List<Branch> vestigingen = queryManager.getVestigingList2();
        for (int i = 0; i < vestigingen.size(); i++) {
        Branch ves = vestigingen.get(i);

            //geeft aan hoe de lijst er uit moet komen te zien
            vestiging_Filter.addItem(ves.getBranchID() + " - " + ves.getEstablishment());
            Datum_DeelnameFilter.setText(dateForm.format(date));
            //geeft de current date weer
            
        }

    }

    //Methode om de Table te vullen met informatie uit de database van table Actiteit
    private void Update_table(int idvestiging, String dag) {
        QueryManager queryManager = BarApplication.getQueryManager();
        ResultSet result = queryManager.GroupActivityFilter2(idvestiging, dag);
        jTableRooster.setModel(DbUtils.resultSetToTableModel(result));
        jTableRooster.removeColumn(jTableRooster.getColumnModel().getColumn(0)); // REMOVE FISRT COLUMN
    }
    
    //Geeft aan op welke manier de filter moet gaan zoeken
    private void set_Table() {
        String vesids = vestiging_Filter.getSelectedItem().toString();
        vesids = vesids.substring(0, vesids.indexOf(" - "));
        int vesid = Integer.parseInt(vesids);

        Update_table(vesid, dagen.getSelectedItem().toString());
    }
    private void TableCoachDeelnemers(){
        QueryManager queryManager = BarApplication.getQueryManager();
        IngevoerdeActiviteiten.setModel(model.DbUtils.resultSetToTableModel(queryManager.getCoachActivity(rs)));
        IngevoerdeActiviteiten.removeColumn(IngevoerdeActiviteiten.getColumnModel().getColumn(0)); // REMOVE FISRT COLUMN
    }
    private void deelnameFilter(String datum){
        QueryManager queryManager = BarApplication.getQueryManager();
        ResultSet result = queryManager.getCoachActivityFilter(datum);
        IngevoerdeActiviteiten.setModel(DbUtils.resultSetToTableModel(result)); 
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jButton_SaveAantal = new javax.swing.JButton();
        deelnemersWijzigen = new javax.swing.JButton();
        deelnemersVerwijderen = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableRooster = new javax.swing.JTable();
        Personalia_JPanel2 = new javax.swing.JPanel();
        jLabel39 = new javax.swing.JLabel();
        begintijd_Activiteit = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        aantalDeelnemers = new javax.swing.JTextField();
        activiteitNaam = new javax.swing.JTextField();
        studio_in = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        eindtijd_Activiteit = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        IngevoerdeActiviteiten = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        zoekActiviteit = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        vestiging_Filter = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        dagen = new javax.swing.JComboBox();
        jPanel6 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        Datum_DeelnameFilter = new javax.swing.JTextField();
        SearchDeelnemersDatum = new javax.swing.JButton();
        jPanel_menu = new javax.swing.JPanel();
        home = new javax.swing.JLabel();
        leden = new javax.swing.JLabel();
        bar = new javax.swing.JLabel();
        factuur = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        jLabel7.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(4, 54, 128));
        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icon-48-article.png"))); // NOI18N
        jLabel7.setText("Activiteit Manager");

        jButton_SaveAantal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/size32/Devices-media-floppy-icon.png"))); // NOI18N
        jButton_SaveAantal.setText("Opslaan");
        jButton_SaveAantal.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jButton_SaveAantal.setInheritsPopupMenu(true);
        jButton_SaveAantal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_SaveAantalActionPerformed(evt);
            }
        });

        deelnemersWijzigen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/size32/edit-icon.png"))); // NOI18N
        deelnemersWijzigen.setText("Wijzigen");
        deelnemersWijzigen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deelnemersWijzigenActionPerformed(evt);
            }
        });

        deelnemersVerwijderen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/size32/Full-Trash-icon.png"))); // NOI18N
        deelnemersVerwijderen.setText("Verwijderen");
        deelnemersVerwijderen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deelnemersVerwijderenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(56, Short.MAX_VALUE)
                .addComponent(jButton_SaveAantal, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deelnemersWijzigen, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deelnemersVerwijderen)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_SaveAantal)
                    .addComponent(deelnemersWijzigen)
                    .addComponent(deelnemersVerwijderen))
                .addGap(8, 8, 8))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(81, 81, 81)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTableRooster.setAutoCreateRowSorter(true);
        jTableRooster.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jTableRooster.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableRoosterMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableRooster);

        Personalia_JPanel2.setBackground(new java.awt.Color(204, 255, 204));
        Personalia_JPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, "Activiteitoverzicht", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 102, 153)))); // NOI18N

        jLabel39.setText("Activiteit naam");

        begintijd_Activiteit.setEditable(false);
        begintijd_Activiteit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                begintijd_ActiviteitActionPerformed(evt);
            }
        });

        jLabel9.setText("Begintijd");

        jLabel3.setText("Aantal Deelnemers");

        activiteitNaam.setEditable(false);

        studio_in.setEditable(false);

        jLabel4.setText("Studio");

        eindtijd_Activiteit.setEditable(false);

        jLabel1.setText("Eindtijd");

        javax.swing.GroupLayout Personalia_JPanel2Layout = new javax.swing.GroupLayout(Personalia_JPanel2);
        Personalia_JPanel2.setLayout(Personalia_JPanel2Layout);
        Personalia_JPanel2Layout.setHorizontalGroup(
            Personalia_JPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Personalia_JPanel2Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(Personalia_JPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(Personalia_JPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(Personalia_JPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel39)
                        .addContainerGap(131, Short.MAX_VALUE))
                    .addGroup(Personalia_JPanel2Layout.createSequentialGroup()
                        .addGroup(Personalia_JPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(activiteitNaam, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(aantalDeelnemers)
                            .addComponent(begintijd_Activiteit)
                            .addComponent(jLabel4)
                            .addComponent(studio_in)
                            .addComponent(jLabel3)
                            .addComponent(jLabel9)
                            .addComponent(eindtijd_Activiteit))
                        .addGap(31, 31, 31))))
        );
        Personalia_JPanel2Layout.setVerticalGroup(
            Personalia_JPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Personalia_JPanel2Layout.createSequentialGroup()
                .addComponent(jLabel39)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(activiteitNaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(studio_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(begintijd_Activiteit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(eindtijd_Activiteit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aantalDeelnemers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        IngevoerdeActiviteiten.setAutoCreateRowSorter(true);
        IngevoerdeActiviteiten.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        IngevoerdeActiviteiten.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                IngevoerdeActiviteitenMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(IngevoerdeActiviteiten);

        jPanel5.setBackground(new java.awt.Color(153, 153, 153));
        jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        zoekActiviteit.setText("Search");
        zoekActiviteit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zoekActiviteitActionPerformed(evt);
            }
        });

        jLabel10.setText("Filter");

        jLabel5.setText("Vestiging");

        jLabel6.setText("Dag");

        dagen.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag" }));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vestiging_Filter, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dagen, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(zoekActiviteit)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zoekActiviteit)
                    .addComponent(jLabel10)
                    .addComponent(vestiging_Filter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(dagen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBackground(new java.awt.Color(153, 153, 153));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Ingevoerde Activiteiten");

        Datum_DeelnameFilter.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        Datum_DeelnameFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Datum_DeelnameFilterActionPerformed(evt);
            }
        });

        SearchDeelnemersDatum.setText("Search");
        SearchDeelnemersDatum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchDeelnemersDatumActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(Datum_DeelnameFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(SearchDeelnemersDatum)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addGap(44, 44, 44))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Datum_DeelnameFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SearchDeelnemersDatum)
                    .addComponent(jLabel11))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        home.setText("Home");
        home.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        home.setFocusCycleRoot(true);
        home.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                homeMouseClicked(evt);
            }
        });

        leden.setText("Leden");
        leden.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        leden.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ledenMouseClicked(evt);
            }
        });

        bar.setText("Bar");
        bar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        bar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                barMouseClicked(evt);
            }
        });

        factuur.setText("Factuur");
        factuur.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        factuur.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                factuurMouseClicked(evt);
            }
        });

        jLabel8.setText("Activiteit");
        jLabel8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel8MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel_menuLayout = new javax.swing.GroupLayout(jPanel_menu);
        jPanel_menu.setLayout(jPanel_menuLayout);
        jPanel_menuLayout.setHorizontalGroup(
            jPanel_menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_menuLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(home)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(leden)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addGap(18, 18, 18)
                .addComponent(factuur)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bar)
                .addContainerGap(756, Short.MAX_VALUE))
        );
        jPanel_menuLayout.setVerticalGroup(
            jPanel_menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_menuLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel_menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(home)
                    .addComponent(leden)
                    .addComponent(bar)
                    .addComponent(factuur)
                    .addComponent(jLabel8))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel_menu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Personalia_JPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel_menu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(Personalia_JPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    //Gegevens worden overgenomen uit de table met als id de eerste row uit de table. 
    //Vervolgends wordt het in de textfields gezet
    private void jTableRoosterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableRoosterMouseClicked
            int row = jTableRooster.getSelectedRow();
            String Table_click = (jTableRooster.getModel().getValueAt(row, 0).toString());
            int activityid = Integer.parseInt(Table_click);
            GroupActivity group = BarApplication.getQueryManager().getGroupActivityRooster(activityid);

            int actId = group.getActivityID();
            GroupActivity gr = BarApplication.getQueryManager().getGroupActivity(actId);
            int studio = group.getStudioID();
            Branch stud = BarApplication.getQueryManager().getVestigingStudio2(studio);

            //als er een id is dan worden de gegevens gevuld.
            if (!(activityid == -1)) {

                activiteitNaam.setText(gr.getActivityname());
                studio_in.setText(stud.getStudio());
                begintijd_Activiteit.setText(group.getBegintijd().toString());
                eindtijd_Activiteit.setText(group.getEindtijd().toString());
            }

    }//GEN-LAST:event_jTableRoosterMouseClicked

    private void begintijd_ActiviteitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_begintijd_ActiviteitActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_begintijd_ActiviteitActionPerformed

    private void zoekActiviteitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoekActiviteitActionPerformed
            if (zoekActiviteit.getText().equals("")){
            zoekActiviteit.setBorder(BorderFactory.createMatteBorder(0, 0, 5, 0, Color.PINK));
            JOptionPane.showMessageDialog(this, "Dag kan niet leeg zijn", "Datum", JOptionPane.ERROR_MESSAGE);
        }else{
            set_Table();

        }
    }//GEN-LAST:event_zoekActiviteitActionPerformed

    private void jButton_SaveAantalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SaveAantalActionPerformed
            
       
        int row = jTableRooster.getSelectedRow();
            if(row >= 0){
            String Table_click = (jTableRooster.getModel().getValueAt(row, 0).toString());
            int activityid = Integer.parseInt(Table_click);
            GroupActivity group = BarApplication.getQueryManager().getGroupActivityRooster(activityid);
            
            group.setAantal(Integer.parseInt(aantalDeelnemers.getText()));
            group.setActivityrooster(activityid);
            
            group.insertCoachActiviteit();
            TableCoachDeelnemers();

            } else{
                JOptionPane.showMessageDialog(this, "Selecteer een activiteit", "activiteit", JOptionPane.ERROR_MESSAGE);
            }
            
            

    }//GEN-LAST:event_jButton_SaveAantalActionPerformed

    private void IngevoerdeActiviteitenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_IngevoerdeActiviteitenMouseClicked
            
 //Slaat het aantal deelmers op van de geselcteerde activiteit op current date.
        int row2 = IngevoerdeActiviteiten.getSelectedRow();
            String Table_click2 = (IngevoerdeActiviteiten.getModel().getValueAt(row2, 0).toString());
            int activityid2 = Integer.parseInt(Table_click2);
            GroupActivity coach = BarApplication.getQueryManager().getCoachActivityRooster(activityid2);
            
            int actId = coach.getActivityrooster();
            GroupActivity activiteitrooster = BarApplication.getQueryManager().getGroupActivityRooster(actId);
            activiteitrooster.getActivityID();
            GroupActivity gr = BarApplication.getQueryManager().getGroupActivity(activiteitrooster.getActivityID());
            int studio = activiteitrooster.getStudioID();
            Branch stud = BarApplication.getQueryManager().getVestigingStudio2(studio);
            
            
            if (!(activityid2 == -1)) {

                activiteitNaam.setText(gr.getActivityname());
                studio_in.setText(stud.getStudio());
                begintijd_Activiteit.setText(activiteitrooster.getBegintijd().toString());
                eindtijd_Activiteit.setText(activiteitrooster.getEindtijd().toString());
                aantalDeelnemers.setText(String.valueOf(coach.getAantal()));
            }
    }//GEN-LAST:event_IngevoerdeActiviteitenMouseClicked

    private void deelnemersWijzigenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deelnemersWijzigenActionPerformed
                //Wijzigen van het aanal deelnemrs van de geselcteerde row/activiteit die al is ingevuld.
        int row2 = IngevoerdeActiviteiten.getSelectedRow();
        String Table_click2 = (IngevoerdeActiviteiten.getModel().getValueAt(row2, 0).toString());
            int activityid2 = Integer.parseInt(Table_click2);
            GroupActivity coach = BarApplication.getQueryManager().getCoachActivityRooster(activityid2);
                
            coach.setAantal(Integer.parseInt(aantalDeelnemers.getText()));
            set_Table();
            TableCoachDeelnemers();            
            coach.updateCoachActiviteit();
            TableCoachDeelnemers();
    }//GEN-LAST:event_deelnemersWijzigenActionPerformed

    private void Datum_DeelnameFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Datum_DeelnameFilterActionPerformed

    }//GEN-LAST:event_Datum_DeelnameFilterActionPerformed

    private void SearchDeelnemersDatumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchDeelnemersDatumActionPerformed
        if (Datum_DeelnameFilter.getText().equals("")){
            TableCoachDeelnemers();
        }else{
        deelnameFilter(Datum_DeelnameFilter.getText());
            } 
    }//GEN-LAST:event_SearchDeelnemersDatumActionPerformed

    private void deelnemersVerwijderenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deelnemersVerwijderenActionPerformed
     //Verwijderen van een ingevulde deelname activiteit   
        int row2 = IngevoerdeActiviteiten.getSelectedRow();
        String Table_click = (IngevoerdeActiviteiten.getModel().getValueAt(row2, 0).toString());
        int activityid2 = Integer.parseInt(Table_click);
        int WarningMessage = JOptionPane.showConfirmDialog(this, "Weet je zeker dat je dit product wil verwijderen", "verwijderen", JOptionPane.YES_NO_OPTION);
        if (WarningMessage == 0) {
            BarApplication.getQueryManager().DeleteRow("coachactiviteit", "idcoachactiviteit", activityid2);
            TableCoachDeelnemers();
        }
    }//GEN-LAST:event_deelnemersVerwijderenActionPerformed

    private void homeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_homeMouseClicked
        // TODO add your handling code here:
        BarApplication.getInstance().showPanel(new Home(login));
    }//GEN-LAST:event_homeMouseClicked

    private void ledenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ledenMouseClicked
        BarApplication.getInstance().showPanel(new MemberOverview(login));
    }//GEN-LAST:event_ledenMouseClicked

    private void barMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_barMouseClicked

        if (evt != null) {
            BarApplication.getInstance().showPanel(new shopping_bar(login));
        }
    }//GEN-LAST:event_barMouseClicked

    private void factuurMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_factuurMouseClicked
        if (evt != null) {
            BarApplication.getInstance().showPanel(new FactuurOverview(login));
        }
    }//GEN-LAST:event_factuurMouseClicked

    private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel8MouseClicked
        // TODO add your handling code here:
        if (evt != null) {

            BarApplication.getInstance().showPanel(new GroupActivityOverview(login));
        }
    }//GEN-LAST:event_jLabel8MouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField Datum_DeelnameFilter;
    private javax.swing.JTable IngevoerdeActiviteiten;
    private javax.swing.JPanel Personalia_JPanel2;
    private javax.swing.JButton SearchDeelnemersDatum;
    private javax.swing.JTextField aantalDeelnemers;
    private javax.swing.JTextField activiteitNaam;
    private javax.swing.JLabel bar;
    private javax.swing.JTextField begintijd_Activiteit;
    private javax.swing.JComboBox dagen;
    private javax.swing.JButton deelnemersVerwijderen;
    private javax.swing.JButton deelnemersWijzigen;
    private javax.swing.JTextField eindtijd_Activiteit;
    private javax.swing.JLabel factuur;
    private javax.swing.JLabel home;
    private javax.swing.JButton jButton_SaveAantal;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    public javax.swing.JPanel jPanel_menu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableRooster;
    private javax.swing.JLabel leden;
    private javax.swing.JTextField studio_in;
    private javax.swing.JComboBox vestiging_Filter;
    private javax.swing.JButton zoekActiviteit;
    // End of variables declaration//GEN-END:variables
}
